<template>
  <div class="app-container">
    <div class="wrap">
      <div class="flex-row justify-between">
        <div class="flex-row">
          <custom-button class="custom-button" @click="addOrganize"></custom-button>
          <!-- 新增 -->
        </div>
      </div>
      <div class="flex-sub table-container">
        <el-table
          v-loading="listLoading"
          :data="list"
          element-loading-text="Loading"
          header-cell-class-name="table-header-cell"
          fit
          highlight-current-row
          :max-height="600"
        >
          <el-table-column align="center" label="序号" width="95">
            <template slot-scope="scope">
              {{ scope.$index + 1 }}
            </template>
          </el-table-column>
          <el-table-column label="OrgCode">
            <template slot-scope="scope">
              <div class="o">
                {{ scope.row.orgCode }}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="园区名称">
            <template slot-scope="scope">
              {{ scope.row.name }}
            </template>
          </el-table-column>
          <el-table-column label="园区地址">
            <template slot-scope="scope">
              <div class="o">
                {{ scope.row.address }}
              </div>
            </template>
          </el-table-column>
          <!-- <el-table-column label="经度">
            <template slot-scope="scope">
              <div class="o">
                  {{ scope.row.content }}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="纬度">
            <template slot-scope="scope">
              <div class="o">
                  {{ scope.row.latitude }}
              </div>
            </template>
          </el-table-column> -->
          <el-table-column label="操作" width="110" align="center">
            <template slot-scope="scope">
              <el-button size="small" type="info" plain @click="update(scope.row.id)">
                修改
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="block">
          <el-pagination
            background
            :total="total"
            :page-size="paging.pageSize"
            layout="total, prev, pager, next, jumper"
            :current-page="paging.pageNo"
            @current-change="handleCurrentChange"
            @size-change="handleSizeChange"
          />
        </div>
      </div>
    </div>
    <!-- 添加/修改 -->
    <el-dialog :title="dialogTit" :visible.sync="formVisible" width="30%">
      <el-form :model="formData">
        <el-form-item label="园区名称：" label-width="18%">
          <el-input v-model="formData.name" autocomplete="off" placeholder="园区名称"></el-input>
        </el-form-item>
        <el-form-item label="园区地址：" label-width="18%">
          <el-input v-model="formData.address" autocomplete="off" placeholder="园区地址"></el-input>
        </el-form-item>
        <!-- <el-form-item label="经纬度：" label-width="18%">
          <el-input v-model="formData.laticontent" autocomplete="off" placeholder="经纬度"></el-input>
        </el-form-item>
        <el-form-item label="登录帐号：" label-width="18%">
          <el-input v-model="formData.account" autocomplete="off"  placeholder="用于园区角色登录帐号"></el-input>
        </el-form-item>
        <el-form-item label="登录密码：" label-width="18%">
          <el-input v-model="formData.password" autocomplete="off" placeholder="密码长度不能小于6位"></el-input>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="formVisible = false">取 消</el-button>
        <el-button type="primary" @click="formVisible = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { handleScreenWidthToVw } from '@/utils/tools'
import { findParkNowList } from '@/child-business/api/maintain'
export default {
  name: 'ParkList',
  components: {},
  data() {
    return {
      formVisible: false,
      formData: {},
      dialogTit: '新增园区',
      newsId: '', // 传入ID
      list: [],
      listLoading: true,
      hasMOre: false,
      moreSearchIf: false,
      record: '',
      paging: {
        pageNo: 1,
        pageSize: 12,
      },
      total: 0,
    }
  },
  computed: {
    handleScreenWidthToVw() {
      return handleScreenWidthToVw
    },
  },
  mounted() {
    this.getList()
  },
  methods: {
    // 添加园区
    addOrganize() {
      this.formVisible = true
      this.dialogTit = '添加园区'
    },
    // 获取当前政府下的园区列表
    getList() {
      this.listLoading = true
      findParkNowList({ ...this.paging }).then(response => {
        console.log(response)
        this.list = response.records
        this.total = response.total
        this.listLoading = false
      })
    },
    // 点击删除
    delPark(id) {
      this.$confirm('确定删除该条数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          console.log('delete')
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除',
          })
        })
    },
    // 点击分页
    handleSizeChange(val) {
      this.paging.pageSize = val
      this.getList()
    },
    // 跳转分页
    handleCurrentChange(val) {
      this.paging.pageNo = val
      this.getList()
    },
    // 修改
    update(row) {
      console.log(row)
    },
  },
}
</script>

<style lang="scss" scoped>
@import '@/child-business/styles/public.scss';
@import '@/child-business/styles/news.scss';
::v-deep .el-form-item__content {
  width: 62%;
}
</style>
